package com.hopu.mybatis02.pojo;

import java.io.Serializable;
import lombok.Data;
@Data
public class R implements Serializable {

    //响应的状态码
    private int code = 200;
    //响应的消息
    private String message = "操作成功";
    //响应的数据
    private Object data;

    private R(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    private R() {
        this(200, "操作成功", null);
    }

    public static R ok() {
        return new R();
    }

    public static R ok(String message) {
        return new R(200, message, null);
    }

    public static R ok(Object data) {
        return new R(200, "操作成功", data);
    }

    public static R ok(String message, Object data) {
        return new R(200, message, data);
    }

    public static R err() {
        return new R(500, "操作失败", null);
    }

    public static R err(String message) {
        return new R(500, message, null);
    }

    public static R err(String message, Object data) {
        return new R(500, message, data);
    }

    public static R err(int code, String message, Object data) {
        return new R(code, message, data);
    }


}